<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>IVF-HNSW: IndexIVF_HNSW.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">IVF-HNSW
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">IndexIVF_HNSW.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef IVF_HNSW_LIB_IVF_HNSW_H</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#define IVF_HNSW_LIB_IVF_HNSW_H</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &lt;fstream&gt;</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &lt;cstdio&gt;</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &lt;unordered_map&gt;</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;</div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#include &lt;faiss/index_io.h&gt;</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#include &lt;faiss/Heap.h&gt;</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#include &lt;faiss/ProductQuantizer.h&gt;</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &lt;faiss/VectorTransform.h&gt;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;faiss/FaissAssert.h&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &lt;faiss/utils.h&gt;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="preprocessor">#include &lt;hnswlib/hnswalg.h&gt;</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="preprocessor">#include &quot;utils.h&quot;</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="keyword">namespace </span>ivfhnsw {</div>
<div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html">   42</a></span>&#160;    <span class="keyword">struct </span><a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html">IndexIVF_HNSW</a></div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    {</div>
<div class="line"><a name="l00044"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#a7c6fb7b945eba6a48d28ea36db5809fc">   44</a></span>&#160;        <span class="keyword">typedef</span> uint32_t <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a7c6fb7b945eba6a48d28ea36db5809fc">idx_t</a>;     </div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;</div>
<div class="line"><a name="l00046"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#a609cc185fcb377f9d8bb5a4e5e7d2c4f">   46</a></span>&#160;        <span class="keywordtype">size_t</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a609cc185fcb377f9d8bb5a4e5e7d2c4f">d</a>;               </div>
<div class="line"><a name="l00047"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#a530ea15e63fa6a6f86cf5feb511c73c3">   47</a></span>&#160;        <span class="keywordtype">size_t</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a530ea15e63fa6a6f86cf5feb511c73c3">nc</a>;              </div>
<div class="line"><a name="l00048"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#a5dabe1116836baf19e25bc1ea89c565c">   48</a></span>&#160;        <span class="keywordtype">size_t</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a5dabe1116836baf19e25bc1ea89c565c">code_size</a>;       </div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;</div>
<div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#ac31af605b0da2dd25cd0dbf51f8a4802">   50</a></span>&#160;        hnswlib::HierarchicalNSW *<a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#ac31af605b0da2dd25cd0dbf51f8a4802">quantizer</a>; </div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;</div>
<div class="line"><a name="l00052"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#aaf630999dcdc300137ffe8f1e93dde21">   52</a></span>&#160;        faiss::ProductQuantizer *<a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#aaf630999dcdc300137ffe8f1e93dde21">pq</a>;         </div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#acff5d189392af6d63db5d782df89f79b">   53</a></span>&#160;        faiss::ProductQuantizer *<a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#acff5d189392af6d63db5d782df89f79b">norm_pq</a>;    </div>
<div class="line"><a name="l00054"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#a45f738ebf5e73b87a11983911d54dd8b">   54</a></span>&#160;        faiss::LinearTransform *<a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a45f738ebf5e73b87a11983911d54dd8b">opq_matrix</a>;  </div>
<div class="line"><a name="l00055"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#a9660b70f02a7b529ef7e997a685e1f5e">   55</a></span>&#160;        <span class="keywordtype">bool</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a9660b70f02a7b529ef7e997a685e1f5e">do_opq</a>;                         </div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;</div>
<div class="line"><a name="l00057"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#a0be6e0ce24b188401271104857283d48">   57</a></span>&#160;        <span class="keywordtype">size_t</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a0be6e0ce24b188401271104857283d48">nprobe</a>;        </div>
<div class="line"><a name="l00058"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#a23f33c7f1b7707580f61c1e69f1373e1">   58</a></span>&#160;        <span class="keywordtype">size_t</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a23f33c7f1b7707580f61c1e69f1373e1">max_codes</a>;     </div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;</div>
<div class="line"><a name="l00060"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#ad40193d01d98d4a55847638581d610bb">   60</a></span>&#160;        std::vector&lt;std::vector&lt;idx_t&gt; &gt; <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#ad40193d01d98d4a55847638581d610bb">ids</a>;           </div>
<div class="line"><a name="l00061"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#ad2ca994b4a3bf65a3fe7d1cf863a0da1">   61</a></span>&#160;        std::vector&lt;std::vector&lt;uint8_t&gt; &gt; <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#ad2ca994b4a3bf65a3fe7d1cf863a0da1">codes</a>;       </div>
<div class="line"><a name="l00062"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#a569a6cca33552f450f253f4d667b6bc4">   62</a></span>&#160;        std::vector&lt;std::vector&lt;uint8_t&gt; &gt; <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a569a6cca33552f450f253f4d667b6bc4">norm_codes</a>;  </div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;    <span class="keyword">protected</span>:</div>
<div class="line"><a name="l00065"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#a16ef4d800329fa8a3b7377e21af659f3">   65</a></span>&#160;        std::vector&lt;float&gt; <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a16ef4d800329fa8a3b7377e21af659f3">norms</a>;           </div>
<div class="line"><a name="l00066"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#a10dd2523ee2de0500e88c256e276f01b">   66</a></span>&#160;        std::vector&lt;float&gt; <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a10dd2523ee2de0500e88c256e276f01b">centroid_norms</a>;  </div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    <span class="keyword">public</span>:</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;        <span class="keyword">explicit</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html">IndexIVF_HNSW</a>(<span class="keywordtype">size_t</span> dim, <span class="keywordtype">size_t</span> ncentroids, <span class="keywordtype">size_t</span> bytes_per_code,</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;                               <span class="keywordtype">size_t</span> nbits_per_idx, <span class="keywordtype">size_t</span> max_group_size = 65536);</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;        <span class="keyword">virtual</span> ~<a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html">IndexIVF_HNSW</a>();</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;        <span class="keywordtype">void</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#ad8520f5a9a46864c038b74116b6d0ba8">build_quantizer</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path_data, <span class="keyword">const</span> <span class="keywordtype">char</span> *path_info, <span class="keyword">const</span> <span class="keywordtype">char</span> *path_edges,</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;                             <span class="keywordtype">size_t</span> M=16, <span class="keywordtype">size_t</span> efConstruction = 500);</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;        <span class="keywordtype">void</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a16438e89ea04032d43b7fea4854fdb09">assign</a> (<span class="keywordtype">size_t</span> n, <span class="keyword">const</span> <span class="keywordtype">float</span> *x, <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a7c6fb7b945eba6a48d28ea36db5809fc">idx_t</a> *labels, <span class="keywordtype">size_t</span> k = 1);</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;        <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a276c84ab9e7117ea021a2ff4e11f4a99">search</a>(<span class="keywordtype">size_t</span> k, <span class="keyword">const</span> <span class="keywordtype">float</span> *x, <span class="keywordtype">float</span> *distances, <span class="keywordtype">long</span> *labels);</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;        <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a750c9093b1fa5adf7d80a9ca6aec5de4">add_batch</a>(<span class="keywordtype">size_t</span> n, <span class="keyword">const</span> <span class="keywordtype">float</span> *x, <span class="keyword">const</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a7c6fb7b945eba6a48d28ea36db5809fc">idx_t</a> *xids, <span class="keyword">const</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a7c6fb7b945eba6a48d28ea36db5809fc">idx_t</a> *precomputed_idx = <span class="keyword">nullptr</span>);</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;        <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a6774efa5e477a077ec9cf4a6d1f52361">train_pq</a>(<span class="keywordtype">size_t</span> n, <span class="keyword">const</span> <span class="keywordtype">float</span> *x);</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;        <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#ab8deedf4590b4ac38b1c83d4f7d44aca">write</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path);</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;        <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#acd6f33b0f7ca53d399f98df18c4a5cc0">read</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *path);</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;        <span class="keywordtype">void</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#ac5a4b723f412d1a54ddee29db4d6a594">compute_centroid_norms</a>();</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;        <span class="keywordtype">void</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a283b84e2daa00165d08e2ed8a1c775ac">rotate_quantizer</a>();</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    <span class="keyword">protected</span>:</div>
<div class="line"><a name="l00136"></a><span class="lineno"><a class="line" href="structivfhnsw_1_1IndexIVF__HNSW.html#a7143a3df1464f0af998ff7cfdf20b19c">  136</a></span>&#160;        std::vector&lt;float&gt; <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a7143a3df1464f0af998ff7cfdf20b19c">precomputed_table</a>;</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;        <span class="keywordtype">float</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#abd20f0d5f3a516996267961a578cd584">pq_L2sqr</a>(<span class="keyword">const</span> uint8_t *code);</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;    <span class="keyword">private</span>:</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;        <span class="keywordtype">void</span> reconstruct(<span class="keywordtype">size_t</span> n, <span class="keywordtype">float</span> *x, <span class="keyword">const</span> <span class="keywordtype">float</span> *decoded_residuals, <span class="keyword">const</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a7c6fb7b945eba6a48d28ea36db5809fc">idx_t</a> *keys);</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;        <span class="keywordtype">void</span> compute_residuals(<span class="keywordtype">size_t</span> n, <span class="keyword">const</span> <span class="keywordtype">float</span> *x, <span class="keywordtype">float</span> *residuals, <span class="keyword">const</span> <a class="code" href="structivfhnsw_1_1IndexIVF__HNSW.html#a7c6fb7b945eba6a48d28ea36db5809fc">idx_t</a> *keys);</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;    };</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;}</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;<span class="preprocessor">#endif //IVF_HNSW_LIB_INDEX_HNSW_H</span></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_ad40193d01d98d4a55847638581d610bb"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#ad40193d01d98d4a55847638581d610bb">ivfhnsw::IndexIVF_HNSW::ids</a></div><div class="ttdeci">std::vector&lt; std::vector&lt; idx_t &gt; &gt; ids</div><div class="ttdoc">Inverted lists for indexes. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:60</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a16438e89ea04032d43b7fea4854fdb09"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a16438e89ea04032d43b7fea4854fdb09">ivfhnsw::IndexIVF_HNSW::assign</a></div><div class="ttdeci">void assign(size_t n, const float *x, idx_t *labels, size_t k=1)</div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.cpp:64</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_ac5a4b723f412d1a54ddee29db4d6a594"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#ac5a4b723f412d1a54ddee29db4d6a594">ivfhnsw::IndexIVF_HNSW::compute_centroid_norms</a></div><div class="ttdeci">void compute_centroid_norms()</div><div class="ttdoc">Compute norms of the HNSW vertices. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.cpp:324</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a276c84ab9e7117ea021a2ff4e11f4a99"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a276c84ab9e7117ea021a2ff4e11f4a99">ivfhnsw::IndexIVF_HNSW::search</a></div><div class="ttdeci">virtual void search(size_t k, const float *x, float *distances, long *labels)</div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.cpp:164</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a5dabe1116836baf19e25bc1ea89c565c"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a5dabe1116836baf19e25bc1ea89c565c">ivfhnsw::IndexIVF_HNSW::code_size</a></div><div class="ttdeci">size_t code_size</div><div class="ttdoc">Code size per vector in bytes. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:48</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a530ea15e63fa6a6f86cf5feb511c73c3"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a530ea15e63fa6a6f86cf5feb511c73c3">ivfhnsw::IndexIVF_HNSW::nc</a></div><div class="ttdeci">size_t nc</div><div class="ttdoc">Number of centroids. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:47</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a7143a3df1464f0af998ff7cfdf20b19c"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a7143a3df1464f0af998ff7cfdf20b19c">ivfhnsw::IndexIVF_HNSW::precomputed_table</a></div><div class="ttdeci">std::vector&lt; float &gt; precomputed_table</div><div class="ttdoc">Size pq.M * pq.ksub. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:136</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a609cc185fcb377f9d8bb5a4e5e7d2c4f"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a609cc185fcb377f9d8bb5a4e5e7d2c4f">ivfhnsw::IndexIVF_HNSW::d</a></div><div class="ttdeci">size_t d</div><div class="ttdoc">Vector dimension. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:46</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_acff5d189392af6d63db5d782df89f79b"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#acff5d189392af6d63db5d782df89f79b">ivfhnsw::IndexIVF_HNSW::norm_pq</a></div><div class="ttdeci">faiss::ProductQuantizer * norm_pq</div><div class="ttdoc">Produces the norm codes of reconstructed base vectors. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:53</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a9660b70f02a7b529ef7e997a685e1f5e"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a9660b70f02a7b529ef7e997a685e1f5e">ivfhnsw::IndexIVF_HNSW::do_opq</a></div><div class="ttdeci">bool do_opq</div><div class="ttdoc">Turn on/off OPQ encoding. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:55</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html">ivfhnsw::IndexIVF_HNSW</a></div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:42</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a16ef4d800329fa8a3b7377e21af659f3"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a16ef4d800329fa8a3b7377e21af659f3">ivfhnsw::IndexIVF_HNSW::norms</a></div><div class="ttdeci">std::vector&lt; float &gt; norms</div><div class="ttdoc">L2 square norms of reconstructed base vectors. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:65</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a750c9093b1fa5adf7d80a9ca6aec5de4"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a750c9093b1fa5adf7d80a9ca6aec5de4">ivfhnsw::IndexIVF_HNSW::add_batch</a></div><div class="ttdeci">virtual void add_batch(size_t n, const float *x, const idx_t *xids, const idx_t *precomputed_idx=nullptr)</div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.cpp:71</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_ab8deedf4590b4ac38b1c83d4f7d44aca"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#ab8deedf4590b4ac38b1c83d4f7d44aca">ivfhnsw::IndexIVF_HNSW::write</a></div><div class="ttdeci">virtual void write(const char *path)</div><div class="ttdoc">Write index to the path. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.cpp:277</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_acd6f33b0f7ca53d399f98df18c4a5cc0"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#acd6f33b0f7ca53d399f98df18c4a5cc0">ivfhnsw::IndexIVF_HNSW::read</a></div><div class="ttdeci">virtual void read(const char *path)</div><div class="ttdoc">Read index from the path. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.cpp:301</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a23f33c7f1b7707580f61c1e69f1373e1"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a23f33c7f1b7707580f61c1e69f1373e1">ivfhnsw::IndexIVF_HNSW::max_codes</a></div><div class="ttdeci">size_t max_codes</div><div class="ttdoc">Max number of codes to visit to do a query. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:58</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_ac31af605b0da2dd25cd0dbf51f8a4802"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#ac31af605b0da2dd25cd0dbf51f8a4802">ivfhnsw::IndexIVF_HNSW::quantizer</a></div><div class="ttdeci">hnswlib::HierarchicalNSW * quantizer</div><div class="ttdoc">Quantizer that maps vectors to inverted lists (HNSW [Y.Malkov]) </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:50</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a569a6cca33552f450f253f4d667b6bc4"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a569a6cca33552f450f253f4d667b6bc4">ivfhnsw::IndexIVF_HNSW::norm_codes</a></div><div class="ttdeci">std::vector&lt; std::vector&lt; uint8_t &gt; &gt; norm_codes</div><div class="ttdoc">PQ codes of norms of reconstructed base vectors. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:62</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a45f738ebf5e73b87a11983911d54dd8b"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a45f738ebf5e73b87a11983911d54dd8b">ivfhnsw::IndexIVF_HNSW::opq_matrix</a></div><div class="ttdeci">faiss::LinearTransform * opq_matrix</div><div class="ttdoc">Rotation matrix for OPQ encoding. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:54</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_abd20f0d5f3a516996267961a578cd584"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#abd20f0d5f3a516996267961a578cd584">ivfhnsw::IndexIVF_HNSW::pq_L2sqr</a></div><div class="ttdeci">float pq_L2sqr(const uint8_t *code)</div><div class="ttdoc">L2 sqr distance function for PQ codes. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.cpp:345</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_ad8520f5a9a46864c038b74116b6d0ba8"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#ad8520f5a9a46864c038b74116b6d0ba8">ivfhnsw::IndexIVF_HNSW::build_quantizer</a></div><div class="ttdeci">void build_quantizer(const char *path_data, const char *path_info, const char *path_edges, size_t M=16, size_t efConstruction=500)</div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.cpp:38</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_aaf630999dcdc300137ffe8f1e93dde21"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#aaf630999dcdc300137ffe8f1e93dde21">ivfhnsw::IndexIVF_HNSW::pq</a></div><div class="ttdeci">faiss::ProductQuantizer * pq</div><div class="ttdoc">Produces the residual codes. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:52</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a10dd2523ee2de0500e88c256e276f01b"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a10dd2523ee2de0500e88c256e276f01b">ivfhnsw::IndexIVF_HNSW::centroid_norms</a></div><div class="ttdeci">std::vector&lt; float &gt; centroid_norms</div><div class="ttdoc">L2 square norms of coarse centroids. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:66</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a283b84e2daa00165d08e2ed8a1c775ac"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a283b84e2daa00165d08e2ed8a1c775ac">ivfhnsw::IndexIVF_HNSW::rotate_quantizer</a></div><div class="ttdeci">void rotate_quantizer()</div><div class="ttdoc">For correct search using OPQ encoding rotate points in the coarse quantizer. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.cpp:332</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a0be6e0ce24b188401271104857283d48"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a0be6e0ce24b188401271104857283d48">ivfhnsw::IndexIVF_HNSW::nprobe</a></div><div class="ttdeci">size_t nprobe</div><div class="ttdoc">Number of probes at search time. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:57</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a6774efa5e477a077ec9cf4a6d1f52361"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a6774efa5e477a077ec9cf4a6d1f52361">ivfhnsw::IndexIVF_HNSW::train_pq</a></div><div class="ttdeci">virtual void train_pq(size_t n, const float *x)</div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.cpp:217</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_ad2ca994b4a3bf65a3fe7d1cf863a0da1"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#ad2ca994b4a3bf65a3fe7d1cf863a0da1">ivfhnsw::IndexIVF_HNSW::codes</a></div><div class="ttdeci">std::vector&lt; std::vector&lt; uint8_t &gt; &gt; codes</div><div class="ttdoc">PQ codes of residuals. </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:61</div></div>
<div class="ttc" id="structivfhnsw_1_1IndexIVF__HNSW_html_a7c6fb7b945eba6a48d28ea36db5809fc"><div class="ttname"><a href="structivfhnsw_1_1IndexIVF__HNSW.html#a7c6fb7b945eba6a48d28ea36db5809fc">ivfhnsw::IndexIVF_HNSW::idx_t</a></div><div class="ttdeci">uint32_t idx_t</div><div class="ttdoc">all indices are this type </div><div class="ttdef"><b>Definition:</b> IndexIVF_HNSW.h:44</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Thu Feb 8 2018 16:55:50 for IVF-HNSW by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.6
</small></address>
</body>
</html>
